
// Hash table class to index values
// In this case it is used to index positions on
// the board.
public class HashTable {
	private int[] table;
	private int size;
	
	// initialise hashtable using the board size
	public HashTable(int rowSize) {
		size = rowSize;
		table = new int[size*size];
	}
	
	// inserts position [row][col] from the board
	// into the index
	public void insert(int row, int col, int pos) {
		table[row*size + col] = pos+1;
	}
	
	// checks to see if position [row][col] already
	// exists. Returns true if so, otherwise false.
	public boolean doesExist(int row, int col) {
		if (table[row*size + col] > 0)
			return true;
		
		return false;
	}
	
	// returns position of board piece in the
	// adjacency list
	public int position(int row, int col) {
		return table[row*size + col]-1;
	}
}
 
	
